home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / ROTL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  462 b   |  20 lines

  1.  /* rotl.c from page 239*/
  2.  #include <stdio.h>
  3.  #include <stdlib.h>
  4.  main(int argc, char **argv)
  5.  {
  6.     int bits;
  7.     unsigned value;
  8.     if(argc < 3)
  9.     {
  10.         printf("usage: %s <hex value (max 4 digits)>\
  11.         <no. bits to rotate left > \n",    argv[0]);
  12.         exit(0);
  13.     }
  14.                     /* Convert arg to unsigned long integer*/
  15. sscanf(argv[1], "%4x", &value);
  16. bits = atoi(argv[2]);
  17. printf("%#4.4x rotated left by %d bits = %#4.4x\n",
  18.     value, bits, _rotl(value, bits));
  19.  
  20.  }